package com.wh.hotel.service.strategy.room;

import com.wh.hotel.param.HotelQueryRoomParam;
import com.wh.hotel.po.StrategySuitRangePo;
import com.wh.hotel.po.SuitHotelRoomPo;
import com.wh.hotel.vo.HotelPriceStrategyVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * @author wenhao
 */
@Slf4j
@Component
public class RoomTypeSuitRange extends SuitRangeAbstract {

    @Override
    public boolean isHit(HotelQueryRoomParam param, HotelPriceStrategyVo strategyVo) {
        StrategySuitRangePo suitRangePo = strategyVo.getSuitRangePo();
        for (SuitHotelRoomPo suitHotelRoomPo : suitRangePo.getSuitHotelRoomPoList()) {
            if (!Objects.equals(suitHotelRoomPo.getHotelId(), param.getHotelId())) {
                continue;
            }
            if (CollectionUtils.isEmpty(suitHotelRoomPo.getRoomTypeIdList())) {
                return true;
            }
            if (suitHotelRoomPo.getRoomTypeIdList().contains(param.getRoomTypeId())) {
                return true;
            }
        }
        return false;
    }
}
